
#ifndef _RTTHREAD_NANO_DEVICE_H_
#define _RTTHREAD_NANO_DEVICE_H_

#include <rtthread.h>

rt_err_t rt_device_register(rt_device_t dev,
                            const char *name,
                            rt_uint16_t flags);

rt_err_t rt_device_unregister(rt_device_t dev);

rt_device_t rt_device_find(const char *name);

#ifdef RT_USING_HEAP

rt_device_t rt_device_create(int type, int attach_size);

void rt_device_destroy(rt_device_t dev);

#endif

rt_err_t rt_device_init(rt_device_t dev);

rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag);

rt_err_t rt_device_close(rt_device_t dev);

rt_size_t rt_device_read(
    rt_device_t dev,
    rt_off_t pos,
    void *buffer,
    rt_size_t size);

rt_size_t rt_device_write(
    rt_device_t dev,
    rt_off_t pos,
    const void *buffer,
    rt_size_t size);

rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg);

rt_err_t rt_device_set_rx_indicate(
    rt_device_t dev,
    rt_err_t (*rx_ind)(rt_device_t dev, rt_size_t size));

rt_err_t rt_device_set_tx_complete(
    rt_device_t dev,
    rt_err_t (*tx_done)(rt_device_t dev, void *buffer));

#endif